<?php


namespace app\user\validate;


use think\Validate;

class UserValidate extends Validate
{
    protected $rule = [
        'name' => 'require|max:30',
        'email' => 'require|email',
        'captcha' => 'require|captcha',
        'password' => 'require|length:5,64',
        'email_captcha' => 'require',
        'type' => 'in:0,1',
        'title' => 'require|max:50',
        'content' => 'require'
    ];

    protected $message = [
        'name' => '用户名不能为空, 不能超过30个字符',
        'email' => '电子邮箱格式不正确',
        'password.require' => '密码不能为空',
        'password.length' => '密码必须大于6位且小于64位',
        'captcha' => '验证码错误1',
        'email_captcha' => '邮箱验证码不能为空',
        'type' => '验证类型不在范围',
        'title' => '标题不能为空',
        'title.max' => '标题字符不能超过50',
        'content' => '讨论内容不能为空'
    ];

    protected $scene = [
        'login' => ['email', 'password'],
        'register' => ['name', 'email', 'password', 'email_captcha'],
        'sendEmail_register' => ['email', 'name', 'type'],
        'writer' => ['title', 'content'],
        'sendEmail_login' => ['email', 'type']
    ];
}